import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

export default new VueRouter({
  mode: 'history', // 改为 history 模式，去除 url 里的 #
  routes: [
    {
      // 首页
      path: '/',
      name: 'index',
      component: () => import('@/views/Home/index')
      // children: [
      //   // 接口详情页
      //   // {
      //   //   path: '/doc-get',
      //   //   name: 'DocGet',
      //   //   component: () => import('@/views/Home/components/doc-get')
      //   // }
      // ]
    },
    {
      path: '/doc-get/:id/',
      // 在打开doc-get时会把doc-api页面设置为默认打开；路由重定向>>>当用户访问 /doc-get时，URL 将会被替换成 /doc-api，然后匹配路由为 /doc-api
      redirect: { name: 'DocApi' },
      name: 'DocGet',
      component: () => import('@/views/Home/components/doc-get'),
      children: [
        {
          path: 'api',
          name: 'DocApi',
          component: () => import('@/views/Home/components/doc-api')
        },
        {
          path: 'error',
          name: 'DocError',
          component: () => import('@/views/Home/components/doc-error')
        },
        {
          path: 'example',
          name: 'DocExample',
          component: () => import('@/views/Home/components/doc-example')
        }
      ]
    }
  ]
})
